﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ElectronicJournal.Account.AuthorAccount
{
    public partial class ProofPayment : System.Web.UI.Page
    {
        private Guid _publicationId;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.Params["id"] != null)
                {
                    
                    _publicationId = Guid.Parse(Request.Params["id"]);
                    ViewState["ArticleId"] = _publicationId;
                    Publication publication = EJournalRepository.Instance.GetPublicationById(_publicationId);
                    if (publication.PubicationReceiptNumber != null)
                    {
                        NumberTBx.Text = publication.PubicationReceiptNumber;
                        OkBtn.Text = "Изменить";
                    }
                }
            }
        }

        protected void OkBtn_Click(object sender, EventArgs e)
        {
            var pubId = Guid.Parse(ViewState["ArticleId"].ToString());
            EJournalRepository.Instance.SaveRecieptNumberPublications(pubId, NumberTBx.Text);
            Response.Redirect("MyAccount.aspx");
        }

        protected void BackBtn_Click(object sender, EventArgs e)
        {
            Response.Redirect("MyAccount.aspx");
        }
    }
}